<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>照片墙</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        body,html{
            width: 100%;
            height: 100%;
        }
        #box{
            width: 100%;
            height: 100%;
        }
        #box ul{
            width: 100%;
            height: 100%;
            list-style: none;
            position: relative;
        }
        #box ul li{
            width: 250px;
            height: 360px;
            /*border: 1px solid #000;*/
            position: absolute;
            /*left: 0;*/
            /*top: 0;*/
            background-color: #fff;
            transition: all 1s;
            box-shadow: 0 0 3px #000;
        }
        #box li img{
            width: 250px;
            height: 360px;
        }
        #box ul li.curr{
            transform:rotate(0deg) translate(-50%,-50%)  scale(1.5)  !important;
            /*transform: rotate(90deg) !important;*/

            left: 50% !important;
            top: 50% !important;
            z-index: 998;
        }
    </style>
</head>
<body>
<div id="box">
    <ul>
        <li><img src="images/01.jpg" alt=""></li>
        <li><img src="images/02.jpg" alt=""></li>
        <li><img src="images/03.jpg" alt=""></li>
        <li><img src="images/04.jpg" alt=""></li>
        <li><img src="images/05.jpg" alt=""></li>
        <li><img src="images/06.jpg" alt=""></li>
        <li><img src="images/07.jpg" alt=""></li>
        <li><img src="images/08.jpg" alt=""></li>
        <li><img src="images/09.jpg" alt=""></li>
        <li><img src="images/10.jpg" alt=""></li>
    </ul>
</div>
<script>
    // 1.获取标签
    var box = document.getElementById('box');
    var oul = box.children[0];
    var list = oul.children;

    // 2.获取屏幕的宽度/高度
    var screenW = document.documentElement.clientWidth - 250;
    var screenH = document.documentElement.clientHeight - 360;


    // 2.遍历
    for (var index = 0; index < list.length; index++) {
           var ele = list[index];
        // 1.位置随机
        var x = getRandom(0,screenW);
        var y = getRandom(0,screenH);

        ele.style.left = x + 'px';
        ele.style.top = y + 'px';

        // 2.旋转角度随机
        var angle = getRandom(0,360);
        ele.style.transform = 'rotate('+angle+'deg)';

        // 3.添加点击事件
        ele.onclick = function () {
            // 1.清空所有
            for(var i = 0; i<list.length; i++){
                list[i].className = '';
            }
            // 2.设置当前
            this.className = 'curr';
        }
    }

    function getRandom(min, max) {
            // 0.9999999 * (100 - 50 + 1) + 50 = 95.9 约等于 95
            return Math.floor( Math.random() * (max - min + 1) + min);
        }
</script>
</body>
</html>